import 'package:flutter/material.dart';
import 'package:wan_android/api/project.dart';
import 'package:wan_android/model/project/tab_bar_type.dart';
import 'package:wan_android/model/project/tab_content_type.dart';

class ProjectPageModel extends ChangeNotifier {

  List<TabBarItemData> _tabBarList = [];
  List<TabContentItem> _tabContentList = [];

  List<TabBarItemData> get tabBarList => _tabBarList;
  List<TabContentItem> get tabContentList => _tabContentList;


  Future getTabBarList() async {
    Map<String, dynamic> response = await getProjectTabs();
    TabBarResp tabBarResp = TabBarResp.fromJson(response);
    if (tabBarResp.data != null) {
      _tabBarList = tabBarResp.data;
    } else {
      _tabBarList = [];
    }
    notifyListeners();
  }

  Future getTabContentList(int cid, int page) async {
    Map<String, dynamic> response = await getProjectTabList(cid, page: page);
    TabContentResp tabContentResp = TabContentResp.fromJson(response);

    if (tabContentResp.data != null && tabContentResp.data.datas != null) {
      _tabContentList = tabContentResp.data.datas;
    } else {
      _tabContentList = [];
    }
    notifyListeners();
    return _tabContentList;
  }
}